package lfm.mpr;

import Toast.ToastLFM_Message;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import AsyncTask.TaskProgressBar_Login;

public class LoginActivity extends Activity{
	
	private Button button_login;
	private EditText edit_text_user;
	private EditText edit_text_password;
	private ImageView new_user;
	
	public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.login);
        
        button_login = (Button) findViewById(R.id.button_login);
        edit_text_user = (EditText) findViewById(R.id.editText_login);
        edit_text_password = (EditText) findViewById(R.id.editText_password);
        new_user = (ImageView) findViewById(R.id.imageView3);
        
        
        //Capturamos el evento del boton "Puntos Jornada" y abrimos el nuevo layout 
        //para ver los puntos de los jugadores por Jornada
        button_login.setOnClickListener(new View.OnClickListener() {
              public void onClick(View v)
              {
              	if(edit_text_user.getText().toString().equals("")){
              		ToastLFM_Message.Show_Alert("", 
              				"El campo Usuario es campo requerido", LoginActivity.this);
              	}
              	else if(edit_text_password.getText().toString().equals("")){
              		ToastLFM_Message.Show_Alert("", 
              				"El campo Password es campo requerido", LoginActivity.this);
              	}
              	else {
              		new TaskProgressBar_Login(LoginActivity.this).
              			execute(edit_text_user.getText().toString(), edit_text_password.getText().toString());
              	}
              }//end_onclick
          });//end_onclick_button_user
        
        new_user.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v)
            {
            	Intent intent = new Intent(LoginActivity.this, NewUserActivity.class);
				startActivity(intent);
            }//end_onclick
        });//end_onclick_button_user
        
	}//end_onCreate
	
	

}//end_Login
